
#include"instr_parsing.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include"Global.h"
#include <string>
#include <bitset>
#include"../OP_enum.h"
#include <regex>
#include <unordered_map>



//十六进制字符串转换为二进制整数的转换函数

//构建一个hashmap映射来查询连续指令地址中指令执行包的首指令的地址：任意指令->该指令所在指令执行包的首指令的指令地址
std::string hexToBinary(const std::string& hex) {
    std::unordered_map<char, std::string> hexToBinMap = {
        {'0', "0000"}, {'1', "0001"}, {'2', "0010"}, {'3', "0011"},
        {'4', "0100"}, {'5', "0101"}, {'6', "0110"}, {'7', "0111"},
        {'8', "1000"}, {'9', "1001"}, {'a', "1010"}, {'b', "1011"},
        {'c', "1100"}, {'d', "1101"}, {'e', "1110"}, {'f', "1111"},
        {'A', "1010"}, {'B', "1011"}, {'C', "1100"}, {'D', "1101"},
        {'E', "1110"}, {'F', "1111"}
    };

    std::string binaryResult;
    for (char c : hex) {
        if (hexToBinMap.find(c) != hexToBinMap.end()) {
            binaryResult += hexToBinMap[c];
        } else {
            std::cerr << "Invalid hex character: " << c << std::endl;
            return "";
        }
    }
    return binaryResult;
}
int VULCR(int src){
    int src1;
    if(src = 0){src1 = VST;}
    else if(src = 1){src1 = VFCR1;}
    else if(src = 2){src1 = VFCR2;}
    else if(src = 3){src1 = VFCR3;}
    else if(src = 4){src1 = VECR;}
    else if(src = 8){src1 = SVR0;}
    else if(src = 27){src1 = VCR;}
    else if(src = 29){src1 = VLR;}
    return src1;
}

int SUCR_MVCCG(int src){
    int src1;
    if(src = 0){src1 = VST;}
    else if(src <= 15){src1 = src + 160;}
    else if(src = 16){src1 = SST;}
    else if(src = 17){src1 = SFCR1;}
    else if(src = 18){src1 = SFCR2;}
    else if(src = 20){src1 = SCR;}
    else if(src = 27){src1 = VCR;}
    else if(src = 29){src1 = VLR;}
    else if(src = 30){src1 = SECR;}
    else if(src = 32){src1 = IER;}
    else if(src = 33){src1 = IFR;}
    else if(src = 34){src1 = IRR;}
    else if(src = 35){src1 = ISTP;}
    else if(src = 36){src1 = EER;}
    else if(src = 37){src1 = EFR;}
    else if(src = 38){src1 = ERR;}
    else if(src = 39){src1 = ESTP;}
    else if(src = 40){src1 = CGCR;}
    else if(src = 41){src1 = CVCCR;}
    return src1;
}
int SUCR_MVCGC(int src){
    int src1;
    if(src = 0){src1 = VST;}
    else if(src <= 15){src1 = src + 160;}
    else if(src = 16){src1 = SST;}
    else if(src = 17){src1 = SFCR1;}
    else if(src = 18){src1 = SFCR2;}
    else if(src = 20){src1 = SCR;}
    else if(src = 27){src1 = VCR;}
    else if(src = 29){src1 = VLR;}
    else if(src = 30){src1 = SECR;}
    else if(src = 32){src1 = IER;}
    else if(src = 33){src1 = ICR;}
    else if(src = 34){src1 = IRR;}
    else if(src = 35){src1 = ISTP;}
    else if(src = 36){src1 = EER;}
    else if(src = 37){src1 = ECR;}
    else if(src = 38){src1 = ERR;}
    else if(src = 39){src1 = ESTP;}
    else if(src = 40){src1 = CGCR;}
    else if(src = 41){src1 = CVCCR;}
    return src1;
}

//单指令解析函数
instruction *instruction_parsing(const std::string& Mycode){   
    int8_t  cond_reg;   
    bool    vector;     
    int8_t  dst_hw_id;  
    uint32_t    opcode;
    //std::vector<base_operand*>* operands;
    instruction *instr=NULL;
    //mycode=std::bitset<40>(Mycode);
    //80位稍后再写
    std::string Reg=Mycode.substr(Mycode.size()-40,3);
    std::bitset<3>reg(Reg);
    //int Cond_Reg = binaryToDecimal(Reg);
    //fwt suggestion: 如果转换过来的十进制整数是有规律的，比如0-6号寄存器，那么直接赋值（考虑好寄存器编号的偏移）即可，减少条件分支，提高效率
    

    if(reg==std::bitset<3>("000")){cond_reg=0;}
    else if(reg==std::bitset<3>("001")){cond_reg=REG0;}
    else if(reg==std::bitset<3>("010")){cond_reg=REG1;}
    else if(reg==std::bitset<3>("011")){cond_reg=REG2;}
    else if(reg==std::bitset<3>("100")){cond_reg=REG3;}
    else if(reg==std::bitset<3>("101")){cond_reg=REG4;}
    else if(reg==std::bitset<3>("110")){cond_reg=REG5;}
    else if(reg==std::bitset<3>("111")){cond_reg=REG6;}

    //const char* v=Mycode[38];
    switch(Mycode[Mycode.size() - 2]){
        case '0': vector=false;break;
        case '1': vector=true;break;
    }//标向量判断

    std::string Instr_type=Mycode.substr(Mycode.size()-5,3);
    std::bitset<3>instr_type(Instr_type);
    //如下是4到7位的指令类型判断，以确定执行硬件类型和指令名
    if(instr_type==std::bitset<3>("000")||instr_type==std::bitset<3>("100")){//长立即数MOV指令（40位）
        std::string Dst=Mycode.substr(4,6);
        uint64_t DST=std::stoull(Dst,nullptr,2);
        std::string Imm=Mycode.substr(10,24);
        uint64_t IMM=std::stoull(Imm,nullptr,2);
        switch (vector){
            case true:
            {   
                opcode=VMOVI24_VIEU;
                dst_hw_id=VIEU_;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
                break;
            }       
            default:
                DST=DST+64;
                opcode=SMOVI24_SIEU;
                dst_hw_id=SIEU_;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
                break;
        }
    }
    
    else if(instr_type==std::bitset<3>("001")||instr_type==std::bitset<3>("101")){//   case '001'/'101':这两种情况是长立即数MOV指令（80位）
        std::string unit=Mycode.substr(Mycode.size()-6,2);
        std::bitset<2>U(unit);
        std::string Dst=Mycode.substr(44,6);
        // std::cout << "Dst bits: " << Dst << std::endl; // Debug output
        uint64_t DST=std::stoull(Dst,nullptr,2);
        // std::cout << "DST value: " << DST << std::endl; // Debug output
        std::string Imm1=Mycode.substr(50,24);
        uint64_t IMM1=std::stoull(Imm1,nullptr,2);
        std::string Imm2=Mycode.substr(0,40);
        uint64_t IMM2=std::stoull(Imm2,nullptr,2);
        uint64_t IMM=(IMM2 << 24) | IMM1;
        switch (vector){
            case true:
            if(U==std::bitset<2>("00")){
                opcode=VMOVI_VIEU;
                dst_hw_id=VIEU_;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            else if(U==std::bitset<2>("01")){
                opcode=VMOVI_VMAC;
                dst_hw_id=VMAC_M1;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            else if(U==std::bitset<2>("10")){
                opcode=VMOVI_VMAC;
                dst_hw_id=VMAC_M2;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            else if(U==std::bitset<2>("11")){
                opcode=VMOVI_VMAC;
                dst_hw_id=VMAC_M3;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            break;
                   
            default:
            //向量寄存器向标量寄存器enum下标转换
            DST=DST+64;
            if(U==std::bitset<2>("00")){
                opcode=SMOVI_SIEU;
                dst_hw_id=SIEU_;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            else if(U==std::bitset<2>("01")){
                opcode=SMOVI_SMAC;
                dst_hw_id=SMAC_M1;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            else if(U==std::bitset<2>("10")){
                opcode=SMOVI_SMAC;
                dst_hw_id=SMAC_M2;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);
                instr->add_imme_op(IMM);
                instr->add_register_op(DST);
            }
            break;
        }
    }
    
    else if(instr_type==std::bitset<3>("011")){//三操作数指令
        std::string unit=Mycode.substr(33,2);
        std::string Op_code=Mycode.substr(28,5);
        std::bitset<2>U(unit);
        std::bitset<5>op_code(Op_code);
        std::string Src1=Mycode.substr(10,6);
        uint64_t SRC1=std::stoull(Src1,nullptr,2);
        std::string Src2=Mycode.substr(16,6);
        uint64_t SRC2=std::stoull(Src2,nullptr,2);
        std::string Src3=Mycode.substr(22,6);
        uint64_t SRC3=std::stoull(Src3,nullptr,2);
        std::string Dst=Mycode.substr(4,6);
        uint64_t DST=std::stoull(Dst,nullptr,2);
        switch (vector){
            case true://向量指令
                {if(U==std::bitset<2>("01")){dst_hw_id=VMAC_M1;}
                else if(U==std::bitset<2>("10")){dst_hw_id=VMAC_M2;}
                else if(U==std::bitset<2>("11")){dst_hw_id=VMAC_M3;}//判断VAMC_id
                else if(U==std::bitset<2>("00")){dst_hw_id=VIEU_;}//VIEU暂且放在这里
            
                if(op_code==std::bitset<5>("01000")){opcode=VFMULAD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("00100")){opcode=VFMULAS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("01100")){opcode=VFMULBD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("00010")){opcode=VFMULBS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("01110")){opcode=VFMULAH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("01111")){opcode=VFMULBH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}// 确定指令名
                break;}
            case false:{//标量指令{
                DST=DST+64;
                SRC1=SRC1+64;
                SRC2=SRC2+64;
                SRC3=SRC3+64;
                if(U==std::bitset<2>("01")){dst_hw_id=SMAC_M1;}
                else if(U==std::bitset<2>("10")){dst_hw_id=SMAC_M2;}//判断SMAC
                else if(U==std::bitset<2>("00")){dst_hw_id=SIEU_;}//SIEU暂且放在这里

                if(op_code==std::bitset<5>("01000")){opcode=SFMULAD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("00100")){opcode=SFMULAS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("01100")){opcode=SFMULBD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("00010")){opcode=SFMULBS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("01110")){opcode=SFMULAH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("01111")){opcode=SFMULBH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}
                else if(op_code==std::bitset<5>("11101")){opcode=SMULAUS32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);} //                 case '11101':opcode=SMULAUS32T_src1_r;break;
                else if(op_code==std::bitset<5>("11010")){opcode=SMULASU32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);} //                 case '11010':opcode=SMULASU32T_src2_imm;break;
                else if(op_code==std::bitset<5>("11110")){opcode=SMULASU32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//case '11110':opcode=SMULASU32T_src1_r;break;
                else if(op_code==std::bitset<5>("11010")){opcode=SMULASU32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//case '11010':opcode=SMULASU32T_src2_imm;break;
                else if(op_code==std::bitset<5>("11100")){opcode=SMULAU32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//case '11100':opcode=SMULAU32T_src1_r;break;
                else if(op_code==std::bitset<5>("11000")){opcode=SMULAU32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//case '11000':opcode=SMULAU32T_src2_imm;break;
                else if(op_code==std::bitset<5>("11111")){opcode=SMULAS32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '11111':opcode=SMULAS32T_src1_r;break;
                else if(op_code==std::bitset<5>("11011")){opcode=SMULAS32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '11011':opcode=SMULAS32T_src2_imm;break;
                else if(op_code==std::bitset<5>("10101")){opcode=SMULBUS32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10101':opcode=SMULBUS32T_src1_r;break;
                else if(op_code==std::bitset<5>("10001")){opcode=SMULBUS32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10001':opcode=SMULBUS32T_src2_imm;break;
                else if(op_code==std::bitset<5>("10110")){opcode=SMULBSU32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10110':opcode=SMULBSU32T_src1_r;break;
                else if(op_code==std::bitset<5>("10010")){opcode=SMULBSU32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10010':opcode=SMULBSU32T_src2_imm;break;
                else if(op_code==std::bitset<5>("10111")){opcode=SMULBS32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10111':opcode=SMULBS32T_src1_r;break;
                else if(op_code==std::bitset<5>("10011")){opcode=SMULBS32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10011':opcode=SMULBS32T_src1_imm;break;
                else if(op_code==std::bitset<5>("10100")){opcode=SMULBU32T_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10100':opcode=SMULBU32T_src1_r,;break;
                else if(op_code==std::bitset<5>("10000")){opcode=SMULBU32T_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '10000':opcode=SMULBU32T_src1_imm;break;
                else if(op_code==std::bitset<5>("00001")){opcode=SFSRT8D;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '00001':opcode=SFSRT8D;break;
                else if(op_code==std::bitset<5>("00011")){opcode=SFSRT8S32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '00011':opcode=SFSRT8S32;break;
                else if(op_code==std::bitset<5>("00101")){opcode=SFNORMD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '00101':opcode=SFNORMD;break;
                else if(op_code==std::bitset<5>("00111")){opcode=SFNORMS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(SRC3);instr->add_register_op(DST);}//                 case '00111':opcode=SFNORMS32;break;
                break;}
            }
            
    }

    else if(instr_type==std::bitset<3>("110")){//     case '110': 长立即数分支指令=>SBR_
        dst_hw_id=SBR_;
        std::string unit=Mycode.substr(33,2);
        std::bitset<2>U(unit);
        std::string Imm=Mycode.substr(4,29);
        uint64_t IMM=std::stoull(Imm,nullptr,2);
        if(U==std::bitset<2>("00")){opcode=SBR_Imm29_imm;instr=new instruction(cond_reg, vector, dst_hw_id, opcode);instr->add_imme_op(IMM);}
        else if(U==std::bitset<2>("01")){opcode=SBRVZ_Imm29_imm;instr=new instruction(cond_reg, vector, dst_hw_id, opcode);instr->add_imme_op(IMM);}
        else if(U==std::bitset<2>("10")){opcode=SBRVNZ_Imm29_imm;instr=new instruction(cond_reg, vector, dst_hw_id, opcode);instr->add_imme_op(IMM);}
    }

    else if(instr_type==std::bitset<3>("010")){//     case '010': 长立即数L/S指令
        // int8_t  ldst_mode;
        std::string Dst=Mycode.substr(4,6);
        uint64_t DST=std::stoull(Dst,nullptr,2);
        std::string Cst18=Mycode.substr(16,18);
        uint64_t CST18=std::stoull(Cst18,nullptr,2);
        std::string ar=Mycode.substr(32,2);
        uint64_t AR=std::stoull(ar,nullptr,2);
        switch (vector){
            case true://向量指令：VLDST
                {const char LS=Mycode[34];
                switch (LS){//判断：LS0/1
                    case '0': dst_hw_id=VLDST_0_;break;
                    case '1': dst_hw_id=VLDST_1_;break;
                }
                std::string LD_ST=Mycode.substr(28,4);
                std::bitset<4>Ld_St(LD_ST);
                AR=AR+132;//对应AR4 5 6 7，AR4=132；
                if(Ld_St==std::bitset<4>("0000")){opcode=VLDH;}//                 case '0000': opcode=VLDH;break;
                else if(Ld_St==std::bitset<4>("0001")){opcode=VLDHU;}//                 case '0001': opcode=VLDHU;break;
                else if(Ld_St==std::bitset<4>("0010")){opcode=VLDW;}//                 case '0010': opcode=VLDW;break;
                else if(Ld_St==std::bitset<4>("0100")){opcode=VLDDW;}//                 case '0100': opcode=VLDDW;break;
                else if(Ld_St==std::bitset<4>("0101")){opcode=VLDDWM2;}//                 case '0101': opcode=VLDDWM2;break;
                else if(Ld_St==std::bitset<4>("0110")){opcode=VLDDWDM2;}//                 case '0110': opcode=VLDDWDM2;break;
                else if(Ld_St==std::bitset<4>("0111")){opcode=VLDDWDM4;}//                 case '0111': opcode=VLDDWDM4;break;
                else if(Ld_St==std::bitset<4>("1000")){opcode=VSTH;}//                 case '1000': opcode=VSTH;break;
                else if(Ld_St==std::bitset<4>("1010")){opcode=VSTW;}//                 case '1010': opcode=VSTW;break;
                else if(Ld_St==std::bitset<4>("1100")){opcode=VSTDW;}//                 case '1100': opcode=VSTDW;break;
                else if(Ld_St==std::bitset<4>("1101")){opcode=VSTDWM16;}//                 case '1101': opcode=VSTDWM16;break;
                else if(Ld_St==std::bitset<4>("1110")){opcode=VSTDWDM16;}//                 case '1110': opcode=VSTDWDM16;break;
                else if(Ld_St==std::bitset<4>("1111")){opcode=VSTDWDM32;}//                 case '1111': opcode=VSTDWDM32;break;
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(DST);instr->add_imme_op(CST18);instr->add_register_op(AR);
                break;
                
            }
       
            case false: //标量指令：SLDST
                {dst_hw_id=SLDST_;
                std::string LD_ST=Mycode.substr(28,4);
                std::cout << "LD_ST bits: " << LD_ST << std::endl; // Debug output
                std::bitset<4>Ld_St(LD_ST);//
                DST = DST + 64;    
                AR = AR + 140;//对应AR12 13 14 15，AR12 = 140
                if(Ld_St==std::bitset<4>("0000")){opcode=SLDH;}//                 case '0000': opcode=SLDH;break;
                else if(Ld_St==std::bitset<4>("0001")){opcode=SLDHU;}
                else if(Ld_St==std::bitset<4>("0010")){opcode=SLDW;}
                else if(Ld_St==std::bitset<4>("0011")){opcode=SLDDW;}
                else if(Ld_St==std::bitset<4>("0100")){opcode=SSTB;}
                else if(Ld_St==std::bitset<4>("0101")){opcode=SSTH;}
                else if(Ld_St==std::bitset<4>("0110")){opcode=SSTW;}
                else if(Ld_St==std::bitset<4>("0111")){opcode=SSTDW;}
                else if(Ld_St==std::bitset<4>("1000")){opcode=SSTDB;}
                else if(Ld_St==std::bitset<4>("1100")){opcode=SLDB;}
                else if(Ld_St==std::bitset<4>("1101")){opcode=SLDBU;}
                else if(Ld_St==std::bitset<4>("1110")){opcode=SLDDB;}
                else if(Ld_St==std::bitset<4>("1111")){opcode=SLDDBU;}
                instr=new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(DST);instr->add_imme_op(CST18);instr->add_register_op(AR);
                break;}
        }
    }
    else if(instr_type==std::bitset<3>("111")){//     case '111':单/双操作数指令
        std::string unit=Mycode.substr(32,3);
        std::string Op_code=Mycode.substr(22,10);
        std::bitset<3>U(unit);
        std::bitset<10>op_code(Op_code);
        std::string Src1=Mycode.substr(10,6);
        uint64_t SRC1=std::stoull(Src1,nullptr,2);
        std::string Src2=Mycode.substr(16,6);
        uint64_t SRC2=std::stoull(Src2,nullptr,2);
        std::string Dst=Mycode.substr(4,6);
        uint64_t DST=std::stoull(Dst,nullptr,2);
        std::string or_=Mycode.substr(14,4);
        uint64_t OR_=std::stoull(or_,nullptr,2);
        std::string const_10=Mycode.substr(14,10);
        uint64_t CONST_10=std::stoull(const_10,nullptr,2);
        std::string ar_=Mycode.substr(10,4);
        uint64_t AR_=std::stoull(ar_,nullptr,2);
        switch (vector){
            case true://向量指令
                if(U==std::bitset<3>("101")){//U"101":VLDST1
                    int8_t  ldst_mode;
                    dst_hw_id=VLDST_1_;
                    std::string LD_ST=Mycode.substr(28,4);
                    std::bitset<4>Ld_St(LD_ST);
                    std::string mode=Mycode.substr(24,4);
                    std::bitset<4>MODE(mode);
                    AR_ = AR_ + 128; //从AR0=128 开始
                    OR_ = OR_ + 144; //从OR0=144 开始
                    if(Ld_St==std::bitset<4>("0000")){opcode=VLDH;}//                 case '0000': opcode=VLDH;break;
                    else if(Ld_St==std::bitset<4>("0001")){opcode=VLDHU;}//                 case '0001': opcode=VLDHU;break;
                    else if(Ld_St==std::bitset<4>("0010")){opcode=VLDW;}//                 case '0010': opcode=VLDW;break;
                    else if(Ld_St==std::bitset<4>("0001")){opcode=VLDDW;}//                 case '0100': opcode=VLDDW;break;
                    else if(Ld_St==std::bitset<4>("0101")){opcode=VLDDWM2;}//                 case '0101': opcode=VLDDWM2;break;
                    else if(Ld_St==std::bitset<4>("0110")){opcode=VLDDWDM2;}//                 case '0110': opcode=VLDDWDM2;break;
                    else if(Ld_St==std::bitset<4>("0111")){opcode=VLDDWDM4;}//                 case '0111': opcode=VLDDWDM4;break;
                    else if(Ld_St==std::bitset<4>("1000")){opcode=VSTH;}//                 case '1000': opcode=VSTH;break;
                    else if(Ld_St==std::bitset<4>("1010")){opcode=VSTW;}//                 case '1010': opcode=VSTW;break;
                    else if(Ld_St==std::bitset<4>("1100")){opcode=VSTDW;}//                 case '1100': opcode=VSTDW;break;
                    else if(Ld_St==std::bitset<4>("1101")){opcode=VSTDWM16;}//                 case '1101': opcode=VSTDWM16;break;
                    else if(Ld_St==std::bitset<4>("1110")){opcode=VSTDWDM16;}//                 case '1110': opcode=VSTDWDM16;break;
                    else if(Ld_St==std::bitset<4>("1111")){opcode=VSTDWDM32;}//                 case '1111': opcode=VSTDWDM32;break;instr->add_register_op(DST);}
                    if(MODE==std::bitset<4>("0001")){ldst_mode=AR_ADD_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0001")){ldst_mode=AR_SUB_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0010")){ldst_mode=AR_ADD_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0011")){ldst_mode=AR_SUB_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0110")){ldst_mode=AR_VAR_ADD;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0111")){ldst_mode=AR_VAR_SUB;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1000")){ldst_mode=AR_ADD_OR_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1001")){ldst_mode=AR_SUB_OR_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1010")){ldst_mode=AR_ADD_OR_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1011")){ldst_mode=AR_SUB_OR_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1110")){ldst_mode=AR_VAR_ADD_OR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1111")){ldst_mode=AR_VAR_SUB_OR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    
                    break;
                }
                else if(U==std::bitset<3>("100")){//U"100":VLDST0
                    int8_t  ldst_mode;
                    dst_hw_id=VLDST_0_;
                    std::string LD_ST=Mycode.substr(28,4);
                    std::bitset<4>Ld_St(LD_ST);
                    std::string mode=Mycode.substr(24,4);
                    std::bitset<4>MODE(mode);
                    AR_ = AR_ + 128; //从AR8=136开始
                    OR_ = OR_ + 144; //从OR8=152开始
                    if(Ld_St==std::bitset<4>("0000")){opcode=VLDH;}//                 case '0000': opcode=VLDH;break;
                    else if(Ld_St==std::bitset<4>("0001")){opcode=VLDHU;}//                 case '0001': opcode=VLDHU;break;
                    else if(Ld_St==std::bitset<4>("0010")){opcode=VLDW;}//                 case '0010': opcode=VLDW;break;
                    else if(Ld_St==std::bitset<4>("0001")){opcode=VLDDW;}//                 case '0100': opcode=VLDDW;break;
                    else if(Ld_St==std::bitset<4>("0101")){opcode=VLDDWM2;}//                 case '0101': opcode=VLDDWM2;break;
                    else if(Ld_St==std::bitset<4>("0110")){opcode=VLDDWDM2;}//                 case '0110': opcode=VLDDWDM2;break;
                    else if(Ld_St==std::bitset<4>("0111")){opcode=VLDDWDM4;}//                 case '0111': opcode=VLDDWDM4;break;
                    else if(Ld_St==std::bitset<4>("1000")){opcode=VSTH;}//                 case '1000': opcode=VSTH;break;
                    else if(Ld_St==std::bitset<4>("1010")){opcode=VSTW;}//                 case '1010': opcode=VSTW;break;
                    else if(Ld_St==std::bitset<4>("1100")){opcode=VSTDW;}//                 case '1100': opcode=VSTDW;break;
                    else if(Ld_St==std::bitset<4>("1101")){opcode=VSTDWM16;}//                 case '1101': opcode=VSTDWM16;break;
                    else if(Ld_St==std::bitset<4>("1110")){opcode=VSTDWDM16;}//                 case '1110': opcode=VSTDWDM16;break;
                    else if(Ld_St==std::bitset<4>("1111")){opcode=VSTDWDM32;}//                 case '1111': opcode=VSTDWDM32;break;
                    if(MODE==std::bitset<4>("0000")){ldst_mode=AR_ADD_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0001")){ldst_mode=AR_SUB_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0010")){ldst_mode=AR_ADD_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0011")){ldst_mode=AR_SUB_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0110")){ldst_mode=AR_VAR_ADD;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0111")){ldst_mode=AR_VAR_SUB;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1000")){ldst_mode=AR_ADD_OR_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1001")){ldst_mode=AR_SUB_OR_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1010")){ldst_mode=AR_ADD_OR_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1011")){ldst_mode=AR_SUB_OR_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1110")){ldst_mode=AR_VAR_ADD_OR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1111")){ldst_mode=AR_VAR_SUB_OR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    
                    break;
                }
                else if(U==std::bitset<3>("001")||U==std::bitset<3>("010")||U==std::bitset<3>("011")){//U"001":VMAC
                    //dst_hw_id=VMAC_M1;
                    if(U==std::bitset<3>("001")){dst_hw_id=VMAC_M1;}
                    else if(U==std::bitset<3>("010")){dst_hw_id=VMAC_M2;}
                    else if(U==std::bitset<3>("011")){dst_hw_id=VMAC_M3;}
                    
                    if(op_code == std::bitset<10>("0010000000")) { opcode = VFMULD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001000000")) { opcode = VFMULS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0011000000")) { opcode = VFDOT32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0000100000")) { opcode = VFCREAL32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0010100000")) { opcode = VFCIMAG32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000000")) { opcode = VFADDH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000001")) { opcode = VFSUBH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000010")) { opcode = VFMULH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000011")) { opcode = VFCMPEH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000100")) { opcode = VFCMPGH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000101")) { opcode = VFCMPLH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000000")) { opcode = VFHINT16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000001")) { opcode = VFHTRU16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000010")) { opcode = VFINTH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000011")) { opcode = VFINTHU16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000100")) { opcode = VFSPHP16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000101")) { opcode = VFHPSP16L; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001111")) { opcode = VFHPSP16H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000110")) { opcode = VFMANH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000111")) { opcode = VFLOGH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001000")) { opcode = VFABSH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100001010")) { opcode = VFMAX16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001001")) { opcode = VFEXTS32L; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001010")) { opcode = VFEXTS32H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001011")) { opcode = VFEXTH16LL; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001100")) { opcode = VFEXTH16LH; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001101")) { opcode = VFEXTH16HL;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110001110")) { opcode = VFEXTH16HH;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0111000000")) //单操作数指令
                    { opcode = VMOV_VMAC;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1000000000")) { opcode = VFCMPED;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1000000100")) { opcode = VFCMPES32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001000")) { opcode = VFCMPGD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001100")) { opcode = VFCMPGS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1000010000")) { opcode = VFCMPLD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000010100")) { opcode = VFCMPLS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010000000")) //单操作数指令
                    { opcode = VFDINT; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010000100")) //单操作数指令
                    { opcode = VFSINT32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010001000")) //单操作数指令
                    { opcode = VFDTRU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010001100")) //单操作数指令
                    { opcode = VFSTRU32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010010000")) //单操作数指令
                    { opcode = VFINTD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010011000")) //单操作数指令
                    { opcode = VFINTDU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010010100")) //单操作数指令
                    { opcode = VFINTS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010011100")) //单操作数指令
                    { opcode = VFINTSU32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010100000")) { opcode = VFDPSP32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101100")) //单操作数指令
                    { opcode = VFSPDP32T; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101000")) //单操作数指令
                    { opcode = VFSPHDP32T; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000000")) //单操作数指令
                    { opcode = VFMAND; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000100")) //single operand instruction
                    { opcode = VFMANS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011001000")) //single operand instruction
                    { opcode = VFLOGD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011001100")) //single operand instruction
                    { opcode = VFLOGS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010000")) //single operand instruction
                    { opcode = VFABSD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010100")) //single operand instruction
                    { opcode = VFABSS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011011000")) //single operand instruction
                    { opcode = VFRSQD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011011100")) //single operand instruction
                    { opcode = VFRSQS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011100000")) //single operand instruction
                    { opcode = VFRCPD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011100100")) //single operand instruction
                    { opcode = VFRCPS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    break;
                }

                else if(U==std::bitset<3>("000")){//U“000”：VIEU
                    dst_hw_id=VIEU_;
                    if(op_code == std::bitset<10>("1110000100")) { opcode = VADD_src1_vr;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1111000100")) { opcode = VADD_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000100")) { opcode = VADDU_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1101000100")) { opcode = VADDU_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010000100")) { opcode = VADD32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000100")) { opcode = VADD32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000100")) { opcode = VADDU32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001000100")) { opcode = VADDU32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000000")) { opcode = VSUB_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111000000")) { opcode = VSUB_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000000")) { opcode = VSUBU_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1101000000")) { opcode = VSUBU_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000010")) { opcode = VSUBC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010000000")) { opcode = VSUB32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000000")) { opcode = VSUB32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000000")) { opcode = VSUBU32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001000000")) { opcode = VSUBU32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000010")) { opcode = VSUBC32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110101000")) { opcode = VSAT; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101000")) { opcode = VSAT32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110100100")) { opcode = VNEG; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010100100")) { opcode = VNEG32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110100000")) { opcode = VABS; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010100000")) { opcode = VABS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110001100")) { opcode = VMAX; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100001100")) { opcode = VMAXU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010001100")) { opcode = VMAX32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001100")) { opcode = VMAXU32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001000")) { opcode = VMIN; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100001000")) { opcode = VMINU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010001000")) { opcode = VMIN32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001000")) { opcode = VMINU32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110010000")) { opcode = VEQ_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111010000")) { opcode = VEQ_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110010010")) { opcode = VLT_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111010010")) { opcode = VLT_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1100010010")) { opcode = VLTU_src1_vr;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1101010010")) { opcode = VLTU_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010010000")) { opcode = VEQ32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010000")) { opcode = VEQ32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010010010")) { opcode = VLT32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010010")) { opcode = VLT32_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1111110001")) { opcode = VMOV_VIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111110010")) { opcode = VMVCGC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(VULCR(DST));break; }
                    else if(op_code == std::bitset<10>("1111110011")) { opcode = VMVCCG; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(VULCR(SRC2));instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011000")) { opcode = VAND_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011000")) { opcode = VAND_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011010")) { opcode = VOR_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011010")) { opcode = VOR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011100")) { opcode = VXOR_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011100")) { opcode = VXOR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011110")) { opcode = VNOT_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011110")) { opcode = VNOT_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110101100")) { opcode = VLZD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101100")) { opcode = VLZD32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0000000000")) { opcode = VSHFLL32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0010000000")) { opcode = VSHFLL32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100000000")) { opcode = VSHFLL_src1_vr;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0110000000")) { opcode = VSHFLL_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0000100000")) { opcode = VSHFLR32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0010100000")) { opcode = VSHFLR32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100100000")) { opcode = VSHFLR_src1_vr;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0110100000")) { opcode = VSHFLR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001000000")) { opcode = VSHFAR32_src1_vr; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0011000000")) { opcode = VSHFAR32_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101000000")) { opcode = VSHFAR_src1_vr;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0111000000")) { opcode = VSHFAR_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000001000")) { opcode = VBCLR32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100001000")) { opcode = VBCLR;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000101000")) { opcode = VBSET32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100101000")) { opcode = VBSET;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0001001000")) { opcode = VBEX32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101001000")) { opcode = VBEX; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001101000")) { opcode = VBTST32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101101000")) { opcode = VBTST;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010001000")) { opcode = VBEXT32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0110001000")) { opcode = VBEXT; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0010101000")) { opcode = VBEXT32U; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0110101000")) { opcode = VBEXTU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0000010000")) { opcode = VBALE2;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000110000")) { opcode = VBALE2H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001010000")) { opcode = VBALE2LH; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001110000")) { opcode = VBALE2HL; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0010010000")) { opcode = VBALE4H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0010110000")) { opcode = VBALE4L;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0011010000")) { opcode = VSBALE2; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0011110000")) { opcode = VSBALE4; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100010000")) { opcode = VUBALE4H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100110000")) { opcode = VUBALE4L; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101010000")) { opcode = VITL2; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101110000")) { opcode = VITL4; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    break;
                }

            case false:{//标量指令
                SRC1 = SRC1+64;
                SRC2 = SRC2+64;
                DST = DST+64;
                AR_ = AR_ + 128; //从AR0=128 开始
                OR_ = OR_ + 144; //从OR0=144 开始
                if(U==std::bitset<3>("001")||U==std::bitset<3>("010")){//U“001”：SMAC1
                    if(U==std::bitset<3>("001")){dst_hw_id=SMAC_M1;}
                    if(U==std::bitset<3>("010")){dst_hw_id=SMAC_M2;}

                    if(op_code==std::bitset<10>("0010000000")){opcode=SFMULD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code==std::bitset<10>("0001000000")){opcode=SFMULS32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code==std::bitset<10>("0011000000")){opcode=SFDOT32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code==std::bitset<10>("0000100000")){opcode=SFCREAL32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code==std::bitset<10>("0010100000")){opcode=SFCIMAG32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code==std::bitset<10>("1100000001")){opcode=SFSUBH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code==std::bitset<10>("1100000000")){opcode=SFADDH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break;}
                    else if(op_code == std::bitset<10>("1100000001")) { opcode = SFSUBH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1100000010")) { opcode = SFMULH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; } 
                    else if(op_code == std::bitset<10>("1100000011")) { opcode = SFCMPEH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000100")) { opcode = SFCMPGH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000101")) { opcode = SFCMPLH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110000000")) 
                    { opcode = SFHINT16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000001")) 
                    { opcode = SFHTRU16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110000010")) 
                    { opcode = SFINTH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110000011")) 
                    { opcode = SFINTHU16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110000100")) { opcode = SFSPHP16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000101")) 
                    { opcode = SFHPSP16L; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001111")) 
                    { opcode = SFHPSP16H;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110000110")) 
                    { opcode = SFMANH16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110000111")) 
                    { opcode = SFLOGH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110001000")) 
                    { opcode = SFABSH16;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1100001010")) { opcode = SFMAX16; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001001")) 
                    { opcode = SFEXTS32L; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001010")) 
                    { opcode = SFEXTS32H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001011")) 
                    { opcode = SFEXTH16LL;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110001100")) 
                    { opcode = SFEXTH16LH; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001101")) 
                    { opcode = SFEXTH16HL; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001110")) 
                    { opcode = SFEXTH16HH; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100111100")) { opcode = SADD32_src1_r_SMAC;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0100101100")) { opcode = SADD32_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100110100")) { opcode = SADDU32_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100100100")) { opcode = SADDU32_src1_imm_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100111000")) { opcode = SADD_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100101000")) { opcode = SADD_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100110000")) { opcode = SADDU_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100100000")) { opcode = SADDU_src1_imm_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100111010")) { opcode = SADDA_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("0100101010")) { opcode = SADDA_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("0101011100")) { opcode = SSUB32_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101001100")) { opcode = SSUB32_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101010100")) { opcode = SSUBU32_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101000100")) { opcode = SSUBU32_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101011000")) { opcode = SSUB_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101001000")) { opcode = SSUB_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101010000")) { opcode = SSUBU_src1_r_SMAC;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101000000")) { opcode = SSUBU_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101011010")) { opcode = SSUBA_src1_r_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("0101001010")) { opcode = SSUBA_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64); break; }
                    else if(op_code == std::bitset<10>("0101111010")) { opcode = SMULISU32_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101101010")) { opcode = SMULISU32_src2_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101111110")) { opcode = SMULIS32_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101101110")) { opcode = SMULIS32_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101110010")) { opcode = SMULIU32_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101100010")) { opcode = SMULIU32_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101111000")) { opcode = SMULISU_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101101000")) { opcode = SMULISU_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101111100")) { opcode = SMULIS_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101101100")) { opcode = SMULIS_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101110000")) { opcode = SMULIU_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101100000")) { opcode = SMULIU_src2_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0111000000")) { opcode = SMOV_SMAC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0111010000")) { opcode = SMVAGA; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("0111011000")) { opcode = SMVAAG; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2+64);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0111001000")) { opcode = SMVAAA; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("0111100000")) 
                    { opcode = SVBCAST; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0111110000")) 
                    { opcode = SVBCAST2; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000000")) { opcode = SFCMPED; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000100")) { opcode = SFCMPES32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001000")) { opcode = SFCMPGD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001100")) { opcode = SFCMPGS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000010000")) { opcode = SFCMPLD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000010100")) { opcode = SFCMPLS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010000000")) 
                    { opcode = SFDINT; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010000100")) 
                    { opcode = SFSINT32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010001000")) 
                    { opcode = SFDTRU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010001100")) 
                    { opcode = SFSTRU32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010010000")) 
                    { opcode = SFINTD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010011000")) 
                    { opcode = SFINTDU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010010100")) 
                    { opcode = SFINTS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010011100")) 
                    { opcode = SFINTSU32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010100000")) { opcode = SFDPSP32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101100")) 
                    { opcode = SFSPDP32T; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101000")) 
                    { opcode = SFSPHDP32T; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000000")) 
                    { opcode = SFMAND; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000100")) 
                    { opcode = SFMANS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011001000")) 
                    { opcode = SFLOGD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011001100")) 
                    { opcode = SFLOGS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010000")) 
                    { opcode = SFABSD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010100")) 
                    { opcode = SFABSS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011011000")) 
                    { opcode = SFRSQD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011011100")) 
                    { opcode = SFRSQS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011100000")) 
                    { opcode = SFRCPD;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1011100100")) 
                    { opcode = SFRCPS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001000000")) { opcode = SFADDD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001000100")) { opcode = SFADDS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001001000")) { opcode = SFSUBD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001001100")) { opcode = SFSUBS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    break;
                }

                else if(U==std::bitset<3>("000")){//U"000":SIEU
                    dst_hw_id=SIEU_;
                    if(op_code == std::bitset<10>("1110000100")) { opcode = SADD_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111000100")) { opcode = SADD_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1100000100")) { opcode = SADDU_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1101000100")) { opcode = SADDU_src1_imm_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110111000")) { opcode = SADDA_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("1111111000")) { opcode = SADDA_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("1010000100")) { opcode = SADD32_src1_r_SIEU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000100")) { opcode = SADD32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000100")) { opcode = SADDU32_src1_r_SIEU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1001000100")) { opcode = SADDU32_src1_imm_SIEU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110000000")) { opcode = SSUB_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111000000")) { opcode = SSUB_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000000")) { opcode = SSUBU_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1101000000")) { opcode = SSUBU_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100000010")) { opcode = SSUBC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110111001")) { opcode = SSUBA_src1_r_SIEU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64); break; }
                    else if(op_code == std::bitset<10>("1111111001")) { opcode = SSUBA_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2+64);instr->add_register_op(DST+64);break; }
                    else if(op_code == std::bitset<10>("1010000000")) { opcode = SSUB32_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011000000")) { opcode = SSUB32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000000")) { opcode = SSUBU32_src1_r_SIEU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001000000")) { opcode = SSUBU32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000000010")) { opcode = SSUBC32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110101000")) { opcode = SSAT; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101000")) { opcode = SSAT32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110100100")) { opcode = SNEG;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010100100")) { opcode = SNEG32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110100000")) { opcode = SABS; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010100000")) { opcode = SABS32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110001100")) { opcode = SMAX; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100001100")) { opcode = SMAXU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010001100")) { opcode = SMAX32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001100")) { opcode = SMAXU32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110001000")) { opcode = SMIN; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100001000")) { opcode = SMINU; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010001000")) { opcode = SMIN32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1000001000")) { opcode = SMINU32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110010000")) { opcode = SEQ_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111010000")) { opcode = SEQ_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110010010")) { opcode = SLT_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1111010010")) { opcode = SLT_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1100010010")) { opcode = SLTU_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1101010010")) { opcode = SLTU_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1010010000")) { opcode = SEQ32_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1011010000")) { opcode = SEQ32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010010010")) { opcode = SLT32_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1011010010")) { opcode = SLT32_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1000010010")) { opcode = SLTU32_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1001010010")) { opcode = SLTU32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111110001")) { opcode = SMOV_SIEU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1111110010")) { opcode = SMVCGC; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(SUCR_MVCCG(DST));break; }
                    else if(op_code == std::bitset<10>("1111110011")) { opcode = SMVCCG; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SUCR_MVCCG(SRC2));instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011000")) { opcode = SAND_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011000")) { opcode = SAND_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011010")) { opcode = SOR_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011010")) { opcode = SOR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011100")) { opcode = SXOR_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1111011100")) { opcode = SXOR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1110011110")) { opcode = SNOT_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1111011110")) { opcode = SNOT_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC2-64);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("1110101100")) { opcode = SLZD; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("1010101100")) { opcode = SLZD32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000000000")) { opcode = SSHFLL32_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010000000")) { opcode = SSHFLL32_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0100000000")) { opcode = SSHFLL_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0110000000")) { opcode = SSHFLL_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000100000")) { opcode = SSHFLR32_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010100000")) { opcode = SSHFLR32_src1_imm;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0100100000")) { opcode = SSHFLR_src1_r;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0110100000")) { opcode = SSHFLR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001000000")) { opcode = SSHFAR32_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0011000000")) { opcode = SSHFAR32_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0101000000")) { opcode = SSHFAR_src1_r; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0111000000")) { opcode = SSHFAR_src1_imm; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0000001000")) { opcode = SBCLR32; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0100001000")) { opcode = SBCLR;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000101000")) { opcode = SBSET32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0100101000")) { opcode = SBSET;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0001001000")) { opcode = SBEX32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101001000")) { opcode = SBEX;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0001101000")) { opcode = SBTST32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101101000")) { opcode = SBTST;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010001000")) { opcode = SBEXT32;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0110001000")) { opcode = SBEXT;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010101000")) { opcode = SBEXT32U; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0110101000")) { opcode = SBEXTU;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000010000")) { opcode = SBALE2;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0000110000")) { opcode = SBALE2H; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001010000")) { opcode = SBALE2LH; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST);break; }
                    else if(op_code == std::bitset<10>("0001110000")) { opcode = SBALE2HL;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010010000")) { opcode = SBALE4H;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0010110000")) { opcode = SBALE4L;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0011010000")) { opcode = SSBALE2;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0011110000")) { opcode = SSBALE4;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0100010000")) { opcode = SUBALE4H;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0100110000")) { opcode = SUBALE4L;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101010000")) { opcode = SITL2;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                    else if(op_code == std::bitset<10>("0101110000")) { opcode = SITL4;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC2);instr->add_register_op(DST); break; }
                }
                
                else if(U==std::bitset<3>("101")){//U"101":SBR_
                    if(op_code==std::bitset<10>("0100000000")){opcode=SINT;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);break;}
                    else if(op_code==std::bitset<10>("0010000000")){opcode=SNOP;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);break;}
                    else if(op_code==std::bitset<10>("0011000000")){opcode=SEP;dst_hw_id=SBR_; instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);break;}
                    else if(op_code==std::bitset<10>("0110000000")){opcode=SWAIT;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);break;}
                    else if(op_code==std::bitset<10>("1010000000")){opcode=SBR_Rx_r;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);break;}
                    else if(op_code==std::bitset<10>("1100000000")){opcode=SBRVZ_Rx_r;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);break;}
                    else if(op_code==std::bitset<10>("1110000000")){opcode=SBRVNZ_Rx_r;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_register_op(SRC1);break;}
                    else if(op_code==std::bitset<10>("0000000000")){ opcode=SIRET_Imm_imm;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);instr->add_imme_op(SRC1-64);break;}
                    // else if(op_code==std::bitset<10>("0000000000")){
                    //     opcode=SIRET_Imm_imm;
                    //     dst_hw_id=SBR_;
                    //     std::string Imm=Mycode.substr(15);
                    //     int IMM=std::stoi(Imm,nullptr,2);
                    //     instr->add_register_op(IMM);
                    //     break;}
                    else if(op_code==std::bitset<10>("0011000000")){opcode=SERET;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);break;}
                    else if(op_code==std::bitset<10>("0101000000")){opcode=SMFENCE;dst_hw_id=SBR_;instr = new instruction(cond_reg,vector,dst_hw_id,opcode);break;}
                    else if(op_code==std::bitset<10>("0111000000")){
                        opcode=SBARRIER_src1_imm;
                        dst_hw_id=SBR_;
                        std::string Imm=Mycode.substr(15,1);//todo
                        uint64_t IMM=std::stoull(Imm,nullptr,2);
                        std::string Imm2=Mycode.substr(11,4);
                        uint64_t IMM2=std::stoull(Imm2,nullptr,2);
                        instr->add_imme_op(IMM);
                        instr->add_imme_op(IMM2);
                        break;}
                }
                else if(U==std::bitset<3>("100")){//U"100":SLDST_
                    int8_t ldst_mode;
                    dst_hw_id=SLDST_;
                    std::string LD_ST=Mycode.substr(28,4);
                    std::cout << "<SLDST> LD_ST: " << LD_ST << std::endl;
                    std::bitset<4>Ld_St(LD_ST);
                    std::string mode=Mycode.substr(24,4);
                    std::bitset<4>MODE(mode);
                    if(Ld_St==std::bitset<4>("0000")){opcode=SLDH;}//                 
                    else if(Ld_St==std::bitset<4>("0001")){opcode=SLDHU;}
                    else if(Ld_St==std::bitset<4>("0010")){opcode=SLDW;}
                    else if(Ld_St==std::bitset<4>("0011")){opcode=SLDDW;}
                    else if(Ld_St==std::bitset<4>("0100")){opcode=SSTB;}
                    else if(Ld_St==std::bitset<4>("0101")){opcode=SSTH;}
                    else if(Ld_St==std::bitset<4>("0110")){opcode=SSTW;}
                    else if(Ld_St==std::bitset<4>("0111")){opcode=SSTDW;}
                    else if(Ld_St==std::bitset<4>("1000")){opcode=SSTDB;}
                    else if(Ld_St==std::bitset<4>("1100")){opcode=SLDB;}
                    else if(Ld_St==std::bitset<4>("1101")){opcode=SLDBU;}
                    else if(Ld_St==std::bitset<4>("1110")){opcode=SLDDB;}
                    else if(Ld_St==std::bitset<4>("1111")){opcode=SLDDBU;}
                    if(MODE==std::bitset<4>("0000")){ldst_mode=AR_ADD_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0001")){ldst_mode=AR_SUB_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0010")){ldst_mode=AR_ADD_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0011")){ldst_mode=AR_SUB_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0110")){ldst_mode=AR_VAR_ADD;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("0111")){ldst_mode=AR_VAR_SUB;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_imme_op(CONST_10);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1000")){ldst_mode=AR_ADD_OR_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1001")){ldst_mode=AR_SUB_OR_CONSTANT;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1010")){ldst_mode=AR_ADD_OR_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1011")){ldst_mode=AR_SUB_OR_VAR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1110")){ldst_mode=AR_VAR_ADD_OR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    else if(MODE==std::bitset<4>("1111")){ldst_mode=AR_VAR_SUB_OR;instr=new instruction(cond_reg,vector,dst_hw_id,opcode,ldst_mode);instr->add_register_op(AR_);instr->add_register_op(OR_);instr->add_register_op(DST);}
                    break;
                }
                 break;
             }
        }        
    }
     return instr;
}
//从汇编文件（txt类型）批量解析指令，输出储存在vector的中的每一个结构体instr_unit
void instr_unit_parsing(const std::string& filename, int cluster_id, DSP_chip * dsp_chip ){
    int para_instr_nums=0;
    if (dsp_chip == nullptr) {
        std::cerr << "Error: dsp_chip is a null pointer." << std::endl;
        return;
    }
    DSP_cluster* cluster = dsp_chip->get_cluster(cluster_id);

    std::ifstream file(filename);
    std::vector<instruction*> instr_buffer;//并行指令缓冲区
    std::vector<addr_size_t> addr_buffer;//并行指令地址缓冲区
    bool flag = false; 
    
    if (!file.is_open()) {
        std::cerr << "Failed to open file: " << filename << std::endl;
        return;
    }
    std::string line;
    std::regex hexPattern(R"((\b[0-9a-fA-F]+)\s*:\s*(\b[0-9a-fA-F]+))"); // 匹配十六进制字符串
    std::regex funcPattern(R"(([0-9a-fA-F]+)\s*<([a-zA-Z_][a-zA-Z0-9_]*)>:)"); // 匹配 <函数名>
    addr_size_t addr_int = 0;
    addr_size_t head_addr = 0;
    std::string funcName = "FunctionName";

    while (std::getline(file, line)) {
        // std::cout << "Parsing line: " << line << std::endl; // 输出当前解析的行
        std::smatch match;
        if (std::regex_search(line, match, hexPattern) && match.size() > 2) {
            // std::cout << "Hex instruction detected: " << line << std::endl; // 输出当前解析的行
            std::string instr_addr=match[1].str(); // 提取冒号前面面的内容
            std::string mycode = match[2].str(); // 提取冒号后面的内容
            mycode.erase(0, mycode.find_first_not_of(" \t")); // 去除前导空格
            
            addr_int = static_cast<addr_size_t>(std::stoul(instr_addr, nullptr, 16));//八位十六进制字符串强制转化为unsigned int
            
            // 检查是否为十六进制数字
            std::string Mycode = hexToBinary(mycode);
            instruction *instr = instruction_parsing(Mycode);
            if (Mycode[Mycode.size() - 1]=='1'){//并行执行判断
                    //para_instr_nums=para_instr_nums+1;
                instr_buffer.push_back(instr);
                addr_buffer.push_back(addr_int);
                flag = true;
            }
            else if(Mycode[Mycode.size() - 1]=='0'){
                para_instr_nums=0;
                if (flag == true){
                    cluster->store_instruction(addr_int,instr,para_instr_nums,addr_buffer[0]);//并行指令包中的最后一条指令地址存储
                    int i=0;
                    for (instruction *value : instr_buffer) {
                        addr_size_t addr_int = addr_buffer[i];
                        para_instr_nums=instr_buffer.size()-i;
                        i=i+1;
                        cluster->store_instruction(addr_int,value,para_instr_nums,addr_buffer[0]);//并行指令地址存储
                    }
                    instr_buffer.clear();
                    addr_buffer.clear();
                    flag = false;
                } else {
                    cluster->store_instruction(addr_int,instr,para_instr_nums,addr_int);//串行指令地址存储
                }         
            }
    
            // if (flag == true){
            //     int i=0;
            //     for (instruction *value : instr_buffer) {
            //         addr_size_t addr_int = addr_buffer[i];
            //         para_instr_nums=instr_buffer.size()-i;
            //         i=i+1;
            //         cluster->store_instruction(addr_int,value,para_instr_nums,addr_buffer[0]);//并行指令地址存储
            //     }
            //     instr_buffer.clear();
            //     addr_buffer.clear();
            //     flag = false;
            // }
        }
        if (std::regex_search(line, match, funcPattern)) {
            // std::cout << "Function detected: " << line << std::endl; // 输出当前解析的行
            cluster->store_function(funcName,head_addr,addr_int);
            // std::cout << "Storing function: " << funcName << " at address: " << std::hex << head_addr << std::dec << std::endl; // 输出存储的函数名和地址
            std::string instr_addr = match[1].str();    // 第1组：地址
            funcName = match[2].str();   // 第2组：函数名
            head_addr = static_cast<addr_size_t>(std::stoul(instr_addr, nullptr, 16));//八位十六进制字符串强制转化为unsigned int
            // std::cout << "Function name: " << funcName << ", Address: " << std::hex << head_addr << std::dec << std::endl; // 输出函数名和地址
        }   

    }
    file.close();
    return;

}